package book;
import Find.*;
import Change.*;

public class Book {
    private int num;
    private String name;
    private String sort;
    private String author;
    private int price;
    private boolean isHired;
    public static Find[] findMethods= new Find[]{null, new FindName(), new FindSort(), new FindAuthor()};

    public Change[] changes = new Change[]{
            null,
            new ChangeName(),
            new ChangeSort(),
            new ChangeAuthor(),
            new ChangePrice()
    };

    public void change(int choice) {
        if(choice == 0) {
            return;
        }
        this.changes[choice].change(this);
    }
    public boolean getIsHired() {
        return this.isHired;
    }
    public void setIsHired(boolean n) {
        this.isHired = n;
    }
    public String getName() {
        return name;
    }

    public String getSort() {
        return sort;
    }

    public String getAuthor() {
        return author;
    }

    /*public static Find.Find[] getFindMethods() {
        return findMethods;
    }*/

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public Book(Book book) {
        this.num = book.num;
        this.name = book.name;
        this.sort = book.sort;
        this.author = book.author;
        this.price = book.price;
    }

    public Book(int num, String name, String sort, String author, int price) {
        this.num = num;
        this.name = name;
        this.sort = sort;
        this.author = author;
        this.price = price;
    }

    public int getPrice() {
        return price;
    }

    public String toString() {
        return "编号: " + this.num + "| 书名: " + this.name + "| 分类: " + this.sort + "| 作者: " + this.author + "| 价格: " + this.price;
    }
}

